package com.opencloud.ywt.provider.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.opencloud.common.model.PageParams;
import com.opencloud.ywt.client.model.entity.*;
import com.opencloud.ywt.provider.mapper.*;
import com.opencloud.ywt.provider.service.BhyfBdbService;
import com.opencloud.ywt.provider.service.BhyfCityService;
import com.opencloud.ywt.provider.service.BhyfStudentService;
import io.swagger.models.auth.In;
import lombok.Value;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;

/**
 * 动量服务
 * @author yeyong
 */

@Slf4j
@Service
@Transactional(rollbackFor = Exception.class)
public class BhyfBdbServiceImpl implements BhyfBdbService {

    @Autowired
    private BhyfBdbLevelCheckMapper bhyfBdbLevelCheckMapper;

    @Autowired
    private BhyfBdbRuleMapper bhyfBdbRuleMapper;

    @Autowired
    private BhyfBdbRuleObjectMapper bhyfBdbRuleObjectMapper;

    @Autowired
    private BhyfBdbLearnCheckMapper bhyfBdbLearnCheckMapper;

    @Autowired
    private BhyfBdbObservDetailMapper bhyfBdbObservDetailMapper;

    @Autowired
    private BhyfBdbEduProjectMapper bhyfBdbEduProjectMapper;

    @Autowired
    private BhyfBflRaspiBindMapper bhyfBflRaspiBindMapper;

    @Autowired
    private BhyfBflRaspiInfoMapper bhyfBflRaspiInfoMapper;

    @Autowired
    private BhyfBdbEnvDataMapper bhyfBdbEnvDataMapper;

    @Autowired
    private BhyfBdbQuestionMapper bhyfBdbQuestionMapper;

    @Autowired
    private BhyfBdbHealthCodeMapper bhyfBdbHealthCodeMapper;

    @Autowired
    private BhyfBdbTodayScoreMapper bhyfBdbTodayScoreMapper;

    @Autowired
    private BhyfBdbTempMapper  bhyfBdbTempMapper;

    @Autowired
    private BhyfBdbWarningTempMapper bhyfBdbWarningTempMapper;

    @Autowired
    private BhyfBdbRecipeMapper bhyfBdbRecipeMapper;

    @Autowired
    private BhyfBdbSportPersonMapper bhyfBdbSportPersonMapper;

    @Autowired
    private BhyfBdbSleepPersonMapper bhyfBdbSleepPersonMapper;

    @Autowired
    private BhyfBdbBaseStationMapper bhyfBdbBaseStationMapper;

    @Autowired
    private BhyfBdbTrackMapper bhyfBdbTrackMapper;

    @Autowired
    private BhyfBdbPreTempMapper bhyfBdbPreTempMapper;


    @Override
    public List<BhyfBdbLevelcheck> findLevelCheckList(PageParams pageParams) {
        BhyfBdbLevelcheck query = pageParams.mapToObject(BhyfBdbLevelcheck.class);
        QueryWrapper<BhyfBdbLevelcheck> queryWrapper = new QueryWrapper();
        queryWrapper.lambda().eq(ObjectUtils.isNotEmpty(query.getGid()), BhyfBdbLevelcheck::getGid,query.getGid());
        queryWrapper.lambda().eq(ObjectUtils.isNotEmpty(query.getClassid()), BhyfBdbLevelcheck::getClassid,query.getClassid());
        queryWrapper.lambda().eq(ObjectUtils.isNotEmpty(query.getCheckmonth()), BhyfBdbLevelcheck::getCheckmonth,query.getCheckmonth());
        queryWrapper.lambda().eq(ObjectUtils.isNotEmpty(query.getAngletype()), BhyfBdbLevelcheck::getAngletype,query.getAngletype());
        queryWrapper.lambda().eq(ObjectUtils.isNotEmpty(query.getRuletype()), BhyfBdbLevelcheck::getRuletype,query.getRuletype());
        queryWrapper.lambda().eq(ObjectUtils.isNotEmpty(query.getPersonid()), BhyfBdbLevelcheck::getPersonid,query.getPersonid());
        queryWrapper.lambda().orderByDesc(BhyfBdbLevelcheck::getChecklevel);
        return bhyfBdbLevelCheckMapper.selectList(queryWrapper);
    }

    @Override
    public List<BhyfBdbRule> findRuleList(int gradenum,int angletype)
    {
        QueryWrapper<BhyfBdbRule> queryWrapper = new QueryWrapper();
        queryWrapper.lambda().eq(gradenum>0, BhyfBdbRule::getGradenum,gradenum);
        queryWrapper.lambda().eq(angletype>0, BhyfBdbRule::getAngletype,angletype);
        return bhyfBdbRuleMapper.selectList(queryWrapper);
    }

    @Override
    public BhyfBdbLevelcheck addLevelcheck(BhyfBdbLevelcheck entiy)
    {
        bhyfBdbLevelCheckMapper.insert(entiy);
        return entiy;
    }

    @Override
    public BhyfBdbLevelcheck updateLevelcheck(BhyfBdbLevelcheck entiy)
    {
        bhyfBdbLevelCheckMapper.updateById(entiy);
        return entiy;
    }

    @Override
    public BhyfBdbLevelcheck findLevelCheckById(Integer id) {
        return bhyfBdbLevelCheckMapper.selectById(id);
    }

    @Override
    public BhyfBdbLevelcheck isExistCheckLevel(Integer perosnid,Integer ruletype,String checkmonth,Integer angletype) {
        QueryWrapper<BhyfBdbLevelcheck> queryWrapper = new QueryWrapper();
        queryWrapper.lambda().eq(ObjectUtils.isNotEmpty(perosnid), BhyfBdbLevelcheck::getPersonid,perosnid);
        queryWrapper.lambda().eq(ObjectUtils.isNotEmpty(ruletype), BhyfBdbLevelcheck::getRuletype,ruletype);
        queryWrapper.lambda().eq(ObjectUtils.isNotEmpty(checkmonth), BhyfBdbLevelcheck::getCheckmonth,checkmonth);
        queryWrapper.lambda().eq(ObjectUtils.isNotEmpty(angletype), BhyfBdbLevelcheck::getAngletype,angletype);
        List<BhyfBdbLevelcheck> bhyfBdbLevelchecks = bhyfBdbLevelCheckMapper.selectList(queryWrapper);
        if(bhyfBdbLevelchecks == null || bhyfBdbLevelchecks.size()==0){
            return null;
        }else{
            return bhyfBdbLevelchecks.get(0);
        }
    }

    @Override
    public BhyfBdbRule addBhyfBdbRule(BhyfBdbRule entiy)
    {
        bhyfBdbRuleMapper.insert(entiy);
        return entiy;
    }


    @Override
    public List<BhyfBdbRuleObject> findRuleObjectList(int angletype, int ruletype)
    {
        QueryWrapper<BhyfBdbRuleObject> queryWrapper = new QueryWrapper();
        queryWrapper.lambda().eq(ruletype>0, BhyfBdbRuleObject::getRuletype,ruletype);
        queryWrapper.lambda().eq(angletype>0, BhyfBdbRuleObject::getAngletype,angletype);
        return bhyfBdbRuleObjectMapper.selectList(queryWrapper);
    }


    @Override
    public List<BhyfBdbLearnCheck> findLearnCheckList(PageParams pageParams) {
        BhyfBdbLearnCheck query = pageParams.mapToObject(BhyfBdbLearnCheck.class);
        QueryWrapper<BhyfBdbLearnCheck> queryWrapper = new QueryWrapper();
        queryWrapper.lambda().eq(ObjectUtils.isNotEmpty(query.getGid()), BhyfBdbLearnCheck::getGid,query.getGid());
        queryWrapper.lambda().eq(ObjectUtils.isNotEmpty(query.getClassid()), BhyfBdbLearnCheck::getClassid,query.getClassid());
        queryWrapper.lambda().eq(ObjectUtils.isNotEmpty(query.getCheckmonth()), BhyfBdbLearnCheck::getCheckmonth,query.getCheckmonth());
        queryWrapper.lambda().eq(ObjectUtils.isNotEmpty(query.getPersonid()), BhyfBdbLearnCheck::getPersonid,query.getPersonid());
        queryWrapper.lambda().orderByDesc(BhyfBdbLearnCheck::getCreatetime);
        return bhyfBdbLearnCheckMapper.selectList(queryWrapper);
    }

    @Override
    public BhyfBdbLearnCheck addLearncheck(BhyfBdbLearnCheck entiy)
    {
        bhyfBdbLearnCheckMapper.insert(entiy);
        return entiy;
    }

    @Override
    public BhyfBdbLearnCheck updateLearncheck(BhyfBdbLearnCheck entiy)
    {
        bhyfBdbLearnCheckMapper.updateById(entiy);
        return entiy;
    }

    @Override
    public BhyfBdbLearnCheck findLearnCheckById(Integer id) {
        return bhyfBdbLearnCheckMapper.selectById(id);
    }

    @Override
    public BhyfBdbLearnCheck isExistLearnCheck(Integer perosnid,String checkmonth) {
        QueryWrapper<BhyfBdbLearnCheck> queryWrapper = new QueryWrapper();
        queryWrapper.lambda().eq(ObjectUtils.isNotEmpty(perosnid), BhyfBdbLearnCheck::getPersonid,perosnid);
        queryWrapper.lambda().eq(ObjectUtils.isNotEmpty(checkmonth), BhyfBdbLearnCheck::getCheckmonth,checkmonth);
        List<BhyfBdbLearnCheck> bhyfBdbLearnChecks = bhyfBdbLearnCheckMapper.selectList(queryWrapper);
        if(bhyfBdbLearnChecks == null || bhyfBdbLearnChecks.size()==0){
            return null;
        }else{
            return bhyfBdbLearnChecks.get(0);
        }
    }

    @Override
    public BhyfBdbObservDetail addBhyfBdbObservDetail(BhyfBdbObservDetail entiy)
    {
        bhyfBdbObservDetailMapper.insert(entiy);
        return entiy;
    }

    @Override
    public BhyfBdbObservDetail updateBhyfBdbObservDetail(BhyfBdbObservDetail entiy)
    {
        bhyfBdbObservDetailMapper.updateById(entiy);
        return entiy;
    }

    @Override
    public BhyfBdbObservDetail getBhyfBdbObservDetailById(Integer id)
    {
        return bhyfBdbObservDetailMapper.selectById(id);
    }

    @Override
    public List<BhyfBdbObservDetail> getBhyfBdbObservDetailByObservId(Integer observid)
    {
        QueryWrapper<BhyfBdbObservDetail> queryWrapper = new QueryWrapper();
        queryWrapper.lambda().eq(ObjectUtils.isNotEmpty(observid), BhyfBdbObservDetail::getObservrecordid,observid);
        return bhyfBdbObservDetailMapper.selectList(queryWrapper);
    }


    @Override
    public int deleteBhyfBdbObservDetailByObservId(Integer observid)
    {
        QueryWrapper<BhyfBdbObservDetail> queryWrapper = new QueryWrapper();
        queryWrapper.lambda().eq(ObjectUtils.isNotEmpty(observid), BhyfBdbObservDetail::getObservrecordid,observid);
        return bhyfBdbObservDetailMapper.delete(queryWrapper);
    }


    @Override
    public BhyfBdbEduProject addBhyfBdbEduProject(BhyfBdbEduProject entiy)
    {
        bhyfBdbEduProjectMapper.insert(entiy);
        return entiy;
    }

    @Override
    public BhyfBdbEduProject updateBhyfBdbEduProject(BhyfBdbEduProject entiy)
    {
        bhyfBdbEduProjectMapper.updateById(entiy);
        return entiy;
    }

    @Override
    public BhyfBdbEduProject findBhyfBdbEduProjectById(Integer id) {
        return bhyfBdbEduProjectMapper.selectById(id);
    }

    @Override
    public List<BhyfBdbEduProject> findBhyfBdbEduProjectList(PageParams pageParams) {
        BhyfBdbEduProject query = pageParams.mapToObject(BhyfBdbEduProject.class);
        QueryWrapper<BhyfBdbEduProject> queryWrapper = new QueryWrapper();
        queryWrapper.lambda().eq(ObjectUtils.isNotEmpty(query.getId()), BhyfBdbEduProject::getId,query.getId());
        queryWrapper.lambda().eq(ObjectUtils.isNotEmpty(query.getClassid()), BhyfBdbEduProject::getClassid,query.getClassid());
        queryWrapper.lambda().eq(ObjectUtils.isNotEmpty(query.getChosedate()), BhyfBdbEduProject::getChosedate,query.getChosedate());
        queryWrapper.lambda().eq(ObjectUtils.isNotEmpty(query.getRulename()), BhyfBdbEduProject::getRulename,query.getRulename());
        queryWrapper.lambda().eq(ObjectUtils.isNotEmpty(query.getRulelevel()), BhyfBdbEduProject::getRulelevel,query.getRulelevel());
        queryWrapper.lambda().eq(ObjectUtils.isNotEmpty(query.getLearnname()), BhyfBdbEduProject::getLearnname,query.getLearnname());
        queryWrapper.lambda().eq(ObjectUtils.isNotEmpty(query.getLearnlevel()), BhyfBdbEduProject::getLearnlevel,query.getLearnlevel());
        queryWrapper.lambda().eq(ObjectUtils.isNotEmpty(query.getType()), BhyfBdbEduProject::getType,query.getType());
        queryWrapper.lambda().orderByDesc(BhyfBdbEduProject::getCreatetime);
        return bhyfBdbEduProjectMapper.selectList(queryWrapper);
    }

    @Override
    public BhyfBflRaspiInfo addBhyfBflRaspiInfo(BhyfBflRaspiInfo entiy)
    {
        bhyfBflRaspiInfoMapper.insert(entiy);
        return entiy;
    }


    @Override
    public BhyfBflRaspiInfo updateBhyfBflRaspiInfo(BhyfBflRaspiInfo entiy)
    {
        bhyfBflRaspiInfoMapper.updateById(entiy);
        return entiy;
    }

    @Override
    public BhyfBflRaspiInfo getBhyfBflRaspiInfoById(Integer id)
    {
        return bhyfBflRaspiInfoMapper.selectById(id);
    }

    @Override
    public List<BhyfBflRaspiInfo> findBhyfBflRaspiInfoList(PageParams pageParams) {
        BhyfBflRaspiInfo query = pageParams.mapToObject(BhyfBflRaspiInfo.class);
        QueryWrapper<BhyfBflRaspiInfo> queryWrapper = new QueryWrapper();
        queryWrapper.lambda().eq(ObjectUtils.isNotEmpty(query.getId()), BhyfBflRaspiInfo::getId,query.getId());
        queryWrapper.lambda().eq(ObjectUtils.isNotEmpty(query.getMac()), BhyfBflRaspiInfo::getMac,query.getMac());
        queryWrapper.lambda().like(ObjectUtils.isNotEmpty(query.getDevicename()), BhyfBflRaspiInfo::getDevicename,query.getDevicename());
        queryWrapper.lambda().eq(ObjectUtils.isNotEmpty(query.getOnlineStatus()), BhyfBflRaspiInfo::getOnlineStatus,query.getOnlineStatus());
        queryWrapper.lambda().eq(ObjectUtils.isNotEmpty(query.getStatus()), BhyfBflRaspiInfo::getStatus,query.getStatus());
        queryWrapper.lambda().orderByDesc(BhyfBflRaspiInfo::getCreatetime);
        return bhyfBflRaspiInfoMapper.selectList(queryWrapper);
    }


    @Override
    public BhyfBflRaspiBind addBhyfBflRaspiBind(BhyfBflRaspiBind entiy)
    {
        bhyfBflRaspiBindMapper.insert(entiy);
        return entiy;
    }


    @Override
    public List<BhyfBflRaspiBind> getBhyfBflRaspiBindByClassId(Integer classid)
    {
        QueryWrapper<BhyfBflRaspiBind> queryWrapper = new QueryWrapper();
        queryWrapper.lambda().eq(ObjectUtils.isNotEmpty(classid), BhyfBflRaspiBind::getCid,classid);
        return bhyfBflRaspiBindMapper.selectList(queryWrapper);
    }

    @Override
    public BhyfBflRaspiBind deleteBhyfBflRaspiBind(BhyfBflRaspiBind entiy)
    {
        QueryWrapper<BhyfBflRaspiBind> queryWrapper = new QueryWrapper();
        queryWrapper.lambda().eq(ObjectUtils.isNotEmpty(entiy.getMac()), BhyfBflRaspiBind::getMac,entiy.getMac());
        queryWrapper.lambda().eq(ObjectUtils.isNotEmpty(entiy.getCid()), BhyfBflRaspiBind::getCid,entiy.getCid());
        bhyfBflRaspiBindMapper.delete(queryWrapper);
        return entiy;
    }

    @Override
    public BhyfBflRaspiInfo getBhyfBflRaspiInfoByMac(String mac)
    {
        QueryWrapper<BhyfBflRaspiInfo> queryWrapper = new QueryWrapper();
        queryWrapper.lambda().eq(ObjectUtils.isNotEmpty(mac), BhyfBflRaspiInfo::getMac,mac);
        return bhyfBflRaspiInfoMapper.selectOne(queryWrapper);
    }

    @Override
    public List<BhyfBdbEnvData> getBdbEnvDataByClass(Integer gid,Integer classid)
    {
        return bhyfBdbEnvDataMapper.getBdbEnvDataByClass(gid,classid);
    }

    @Override
    public List<BhyfBdbEnvData> getLastBdbEnvDataByClass(Integer gid,Integer classid)
    {
        return bhyfBdbEnvDataMapper.getLastBdbEnvDataByClass(gid,classid);
    }

    @Override
    public List<BhyfBdbQuestion> getBhyfBdbQuestionByPerson(Integer personid,String checkdate)
    {
        return bhyfBdbQuestionMapper.getBhyfBdbQuestionByPerson(personid,checkdate);
    }

    @Override
    public BhyfBdbQuestion addBhyfBdbQuestion(BhyfBdbQuestion entiy)
    {
        bhyfBdbQuestionMapper.insert(entiy);
        return entiy;
    }

    @Override
    public List<BhyfBdbHealthCode> getBhyfBdbHealthCodeByPerson(Integer personid,String checkdate)
    {
        QueryWrapper<BhyfBdbHealthCode> queryWrapper = new QueryWrapper();
        queryWrapper.lambda().eq(ObjectUtils.isNotEmpty(personid), BhyfBdbHealthCode::getPersonid,personid);
        queryWrapper.lambda().eq(ObjectUtils.isNotEmpty(checkdate), BhyfBdbHealthCode::getCheckdate,checkdate);
        return bhyfBdbHealthCodeMapper.selectList(queryWrapper);
    }

    @Override
    public BhyfBdbHealthCode addBdbHealthCode(BhyfBdbHealthCode entiy)
    {
        bhyfBdbHealthCodeMapper.insert(entiy);
        return entiy;
    }

    @Override
    public List<BhyfBdbTodayScore> getBdbTodayScoreByPerson(Integer personid,String checkdate)
    {
        QueryWrapper<BhyfBdbTodayScore> queryWrapper = new QueryWrapper();
        queryWrapper.lambda().eq(ObjectUtils.isNotEmpty(personid), BhyfBdbTodayScore::getPersonid,personid);
        queryWrapper.lambda().eq(ObjectUtils.isNotEmpty(checkdate), BhyfBdbTodayScore::getCheckdate,checkdate);
        return bhyfBdbTodayScoreMapper.selectList(queryWrapper);
    }

    @Override
    public BhyfBdbTodayScore addBdbTodayScore(BhyfBdbTodayScore entiy)
    {
        bhyfBdbTodayScoreMapper.insert(entiy);
        return entiy;
    }

    @Override
    public List<BhyfBdbTemp> getBdbTempByPerson(String mac,String checkdate)
    {
        QueryWrapper<BhyfBdbTemp> queryWrapper = new QueryWrapper();
        queryWrapper.lambda().eq(ObjectUtils.isNotEmpty(mac), BhyfBdbTemp::getMac,mac);
        queryWrapper.lambda().between(ObjectUtils.isNotEmpty(checkdate), BhyfBdbTemp::getChecktime,checkdate+" 00:00:01",checkdate+" 23:59:59");
        return bhyfBdbTempMapper.selectList(queryWrapper);
    }

    @Override
    public List<BhyfBdbTemp> getLastTempListByMac(String mac,String starttime,String endtime)
    {
        return bhyfBdbTempMapper.getLastTempListByMac(mac,starttime,endtime);
    }


    @Override
    public List<BhyfBdbTemp> getLastTempListByClass(Integer classid,String starttime,String endtime)
    {
        return bhyfBdbTempMapper.getLastTempListByClass(classid,starttime,endtime);
    }

    @Override
    public List<BhyfBdbWarningTemp> getBdbWarningTempByPerson(String mac,String checkdate)
    {
        QueryWrapper<BhyfBdbWarningTemp> queryWrapper = new QueryWrapper();
        queryWrapper.lambda().eq(ObjectUtils.isNotEmpty(mac), BhyfBdbWarningTemp::getMac,mac);
        queryWrapper.lambda().between(ObjectUtils.isNotEmpty(checkdate), BhyfBdbWarningTemp::getChecktime,checkdate+" 00:00:01",checkdate+" 23:59:59");
        return bhyfBdbWarningTempMapper.selectList(queryWrapper);
    }

    @Override
    public List<BhyfBdbRecipe> getBdbRecipeList(Integer gid,String starttime,String endtime)
    {
        return bhyfBdbRecipeMapper.getBdbRecipeList(gid,starttime,endtime);
    }

    @Override
    public List<BhyfXhbSportPersonComment> findPersonSportList(Integer gid, Integer personid,String starttime,String endtime)
    {
        List<BhyfXhbSportPersonComment> returnList = new ArrayList<>();
        returnList= bhyfBdbSportPersonMapper.getSportPersonList(gid,personid,starttime,endtime);
        return returnList;
    }

    @Override
    public List<BhyfXhbSportClass> findClassSportList(Integer gid, Integer classid,String starttime,String endtime)
    {
        List<BhyfXhbSportClass> returnList = new ArrayList<>();
        returnList= bhyfBdbSportPersonMapper.getSportClassList(gid,classid,starttime,endtime);
        return returnList;
    }

    @Override
    public List<BhyfXhbSportPersonCommentResult> findGradeSportList(Integer gid, Integer gradenum,String starttime,String endtime)
    {
        List<BhyfXhbSportPersonCommentResult> returnList = new ArrayList<>();
        returnList= bhyfBdbSportPersonMapper.getSportGradeList(gid,gradenum,starttime,endtime);
        return returnList;
    }

    @Override
    public List<BhyfBdbSportPerson> getBhyfBdbSportPersonList(String mac,String checkdate)
    {
        QueryWrapper<BhyfBdbSportPerson> queryWrapper = new QueryWrapper();
        queryWrapper.lambda().eq(ObjectUtils.isNotEmpty(mac), BhyfBdbSportPerson::getMac,mac);
        queryWrapper.lambda().eq(ObjectUtils.isNotEmpty(checkdate), BhyfBdbSportPerson::getSportdate,checkdate);
        return bhyfBdbSportPersonMapper.selectList(queryWrapper);
    }


    @Override
    public List<BhyfBdbSleepPerson> getBhyfBdbSleepPersonList(String mac,String checkdate)
    {
        QueryWrapper<BhyfBdbSleepPerson> queryWrapper = new QueryWrapper();
        queryWrapper.lambda().eq(ObjectUtils.isNotEmpty(mac), BhyfBdbSleepPerson::getMac,mac);
        queryWrapper.lambda().eq(ObjectUtils.isNotEmpty(checkdate), BhyfBdbSleepPerson::getSleepdate,checkdate);
        return bhyfBdbSleepPersonMapper.selectList(queryWrapper);
    }

    @Override
    public List<BhyfBdbBaseStation> getBhyfBdbBaseStationList(Integer gid, Integer classid,String mac)
    {
        QueryWrapper<BhyfBdbBaseStation> queryWrapper = new QueryWrapper();
        queryWrapper.lambda().eq(ObjectUtils.isNotEmpty(mac), BhyfBdbBaseStation::getMac,mac);
        queryWrapper.lambda().eq(ObjectUtils.isNotEmpty(gid), BhyfBdbBaseStation::getGid,gid);
        queryWrapper.lambda().eq(ObjectUtils.isNotEmpty(classid), BhyfBdbBaseStation::getClassid,classid);
        return bhyfBdbBaseStationMapper.selectList(queryWrapper);
    }

    @Override
    public BhyfBdbBaseStation addBhyfBdbBaseStation(BhyfBdbBaseStation entiy)
    {
        bhyfBdbBaseStationMapper.insert(entiy);
        return entiy;
    }


    @Override
    public BhyfBdbBaseStation updateBhyfBdbBaseStation(BhyfBdbBaseStation entiy)
    {
        bhyfBdbBaseStationMapper.updateById(entiy);
        return entiy;
    }


    @Override
    public BhyfBdbBaseStation getBhyfBdbBaseStationById(Integer id)
    {
        return bhyfBdbBaseStationMapper.selectById(id);
    }

    @Override
    public Integer deleteBhyfBdbBaseStation(String mac)
    {
        QueryWrapper<BhyfBdbBaseStation> queryWrapper = new QueryWrapper();
        queryWrapper.lambda().eq(ObjectUtils.isNotEmpty(mac), BhyfBdbBaseStation::getMac,mac);
        return bhyfBdbBaseStationMapper.delete(queryWrapper);
    }

    @Override
    public List<BhyfBdbQuestion> getBhyfBdbQuestionByClass(Integer gid,Integer gradenum,Integer classid,String checkdate)
    {
        return bhyfBdbQuestionMapper.getBhyfBdbQuestionByClass(gid,gradenum, classid,checkdate);
    }

    @Override
    public List<BhyfBdbHealthCode> getBhyfBdbHealthCodeByClass(Integer gid, Integer classid,String checkdate)
    {
        return bhyfBdbHealthCodeMapper.getBhyfBdbHealthCodeByClass(gid,classid,checkdate);
    }

    @Override
    public BhyfBdbTrack addBhyfBdbTrack(BhyfBdbTrack entiy)
    {
        bhyfBdbTrackMapper.insert(entiy);
        return entiy;
    }

    @Override
    public List<BhyfBdbTrack> getBhyfBdbTrackList(Integer gid, Integer classid,Integer tracktype,String trackdate)
    {
        QueryWrapper<BhyfBdbTrack> queryWrapper = new QueryWrapper();
        queryWrapper.lambda().eq(ObjectUtils.isNotEmpty(tracktype), BhyfBdbTrack::getTracktype,tracktype);
        queryWrapper.lambda().eq(ObjectUtils.isNotEmpty(gid), BhyfBdbTrack::getGid,gid);
        queryWrapper.lambda().eq(ObjectUtils.isNotEmpty(classid), BhyfBdbTrack::getClassid,classid);
        queryWrapper.lambda().eq(ObjectUtils.isNotEmpty(trackdate), BhyfBdbTrack::getTrackdate,trackdate);
        return bhyfBdbTrackMapper.selectList(queryWrapper);
    }

    @Override
    public BhyfBdbPreTemp addBhyfBdbPreTemp(BhyfBdbPreTemp entiy)
    {
        bhyfBdbPreTempMapper.insert(entiy);
        return entiy;
    }


    @Override
    public List<BhyfBdbPreTemp> getLastPreTempListByMac(String mac,String starttime,String endtime)
    {
        return bhyfBdbPreTempMapper.getLastPreTempListByMac(mac,starttime,endtime);
    }


    @Override
    public List<BhyfBdbPreTemp> getLastPreTempListByClass(Integer classid,String starttime,String endtime)
    {
        return bhyfBdbPreTempMapper.getLastPreTempListByClass(classid,starttime,endtime);
    }


    @Override
    public List<BhyfBdbWarningTemp> getBdbWarningTempByClass(Integer classid,String starttime,String endtime)
    {
        return bhyfBdbWarningTempMapper.getBdbWarningTempByClass(classid,starttime,endtime);
    }

    @Override
    public List<BhyfBdbWarningTemp> getBdbWarningTempByGradenum(Integer gid,Integer gradenum,Integer classid,String starttime,String endtime)
    {
        return bhyfBdbWarningTempMapper.getBdbWarningTempByGradenum(gid,gradenum,classid,starttime,endtime);
    }

    @Override
    public List<BhyfXhbSleepPerson> findPersonSleepList(Integer gid,String starttime,String endtime)
    {
        List<BhyfXhbSleepPerson> returnList = new ArrayList<>();
        returnList= bhyfBdbSleepPersonMapper.getSleepPersonList(gid,starttime,endtime);
        return returnList;
    }

    @Override
    public List<BhyfXhbSleepClass> findClassSleepList(Integer gid,Integer gradenum, Integer classid,String starttime,String endtime)
    {
        List<BhyfXhbSleepClass> returnList = new ArrayList<>();
        returnList= bhyfBdbSleepPersonMapper.getSleepClassList(gid,gradenum,classid,starttime,endtime);
        return returnList;
    }


    @Override
    public BhyfBdbWarningTemp addBhyfBdbWarningTemp(BhyfBdbWarningTemp entiy)
    {
        bhyfBdbWarningTempMapper.insert(entiy);
        return entiy;
    }

    @Override
    public List<BhyfBdbClassCount> getHealthcodeCountByClass(Integer gid,String checkdate)
    {
        return bhyfBdbTempMapper.getHealthcodeCountByClass(gid,checkdate);
    }

    @Override
    public List<BhyfBdbClassCount> getPreTempCheckCountByClass(Integer gid,String starttime,String endtime)
    {
        return bhyfBdbTempMapper.getPreTempCheckCountByClass(gid,starttime,endtime);
    }

    @Override
    public List<BhyfBdbClassCount> getTempCheckCountByClass(Integer gid,String starttime,String endtime)
    {
        return bhyfBdbTempMapper.getTempCheckCountByClass(gid,starttime,endtime);
    }

    @Override
    public List<BhyfBdbClassCount> getWarnTempCheckCountByClass(Integer gid,String starttime,String endtime)
    {
        return bhyfBdbTempMapper.getWarnTempCheckCountByClass(gid,starttime,endtime);
    }

    @Override
    public List<BhyfBdbClassCount> getTrackCountByClass(Integer gid,Integer tracktype,String checkdate)
    {
        return bhyfBdbTempMapper.getTrackCountByClass(gid,tracktype,checkdate);
    }

    @Override
    public List<BhyfStudent> getUnWearStudentList(Integer gid,Integer classid,String starttime,String endtime)
    {
        return bhyfBdbTempMapper.getUnWearStudentList(gid,classid,starttime,endtime);
    }

    @Override
    public List<BhyfBdbBadSleep> getBadSleepList(Integer gid,Integer classid,Integer personid,String starttime,String endtime)
    {
        return bhyfBdbSleepPersonMapper.getBadSleepPersonList(gid,classid,personid,starttime,endtime);
    }

    @Override
    public List<BhyfBdbMostTemp> getMostTempListByClass(Integer gid,Integer classid,String starttime,String endtime,Integer isbad)
    {
        return bhyfBdbTempMapper.getMostTempListByClass(gid,classid,starttime,endtime,isbad);
    }

    @Override
    public List<BhyfBdbTemp> getLastTempListByGrade(Integer gid,Integer gradenum,Integer classid,String starttime,String endtime)
    {
        return bhyfBdbTempMapper.getLastTempListByGrade(gid,gradenum,classid,starttime,endtime);
    }

    @Override
    public List<BhyfBdbSportPerson> getSportPersonListByClass(Integer gid,Integer classid,String sportdate)
    {
        return  bhyfBdbSportPersonMapper.getSportPersonListByClass(gid,classid,sportdate);
    }

    @Override
    public List<BhyfBdbTemp> getGardenBadTempWatchList(Integer gid,Integer gradenum,Integer classid,String starttime,String endtime)
    {
        return bhyfBdbTempMapper.getGardenBadTempWatchList(gid,gradenum,classid,starttime,endtime);
    }

    @Override
    public List<BhyfBdbDayTempCount> getGardenDayTempCount(Integer gid,String starttime,String endtime)
    {
        return bhyfBdbTempMapper.getGardenDayTempCount(gid,starttime,endtime);
    }
}